package com.aierjun.camera.photo;


import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.MotionEvent;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.SeekBar;

import com.aierjun.camera.R;
import com.aierjun.camera.widget.PhotoCameraView;
import com.aierjun.camera.widget.FocusImageView;


public class PhotoActivity extends AppCompatActivity {
    private PhotoCameraView photoCameraView;
    /**
     * 触摸屏幕时显示的聚焦图案
     */
    private FocusImageView focusImageView;

    private ImageView shutterImageView;

    private ImageView backImageView;

    private RelativeLayout controller_rl;

    private ImageView btn_flashlight;

    private ImageView btn_lenses;

    private SeekBar zoom_seekbar;

    private TakePhotoManager takePhotoManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo);
        findView();
        initView();
    }

    private void findView() {
        photoCameraView = findViewById(R.id.cameraView);
        focusImageView = findViewById(R.id.focusImageView);
        backImageView = findViewById(R.id.backImageView);
        shutterImageView = findViewById(R.id.shutterImageView);
        controller_rl = findViewById(R.id.controller_rl);
        btn_flashlight = findViewById(R.id.btn_flashlight);
        btn_lenses = findViewById(R.id.btn_lenses);
        zoom_seekbar = findViewById(R.id.zoom_seekbar);
    }

    private void initView() {
        takePhotoManager = TakePhotoManager.getInstance(this);
        takePhotoManager.initCamera(photoCameraView)
                .initFocusImageView(focusImageView)
                .initSensorControler()
                .initControllerRLChildView(controller_rl, backImageView, shutterImageView, btn_lenses, btn_flashlight)
                .initZoomSeekBar(zoom_seekbar)
                .setLocation("31/1,58/1,253560/10000","118/1,44/1,491207/10000");

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return takePhotoManager.onTouchEvent(event);
    }

    @Override
    protected void onStart() {
        takePhotoManager.onStart();
        super.onStart();
    }

    @Override
    protected void onStop() {
        takePhotoManager.onStop();
        super.onStop();
    }

    @Override
    protected void onDestroy() {
        takePhotoManager.onDestroy();
        super.onDestroy();
    }
}
